<?php include PATH_TPL."/admin/tpl.header.phtml"?>
<div class="main-container inner">
    <div class="main-content">
        <div class="container-fluid">
            <div class="row bt">
                <div class="col-lg-12 bg">
                    <ol class="breadcrumb">
                        <li class="active">
                            <i class="fa  fa-fw fa-reorder"></i>新增配餐
                        </li>
                    </ol>
                </div>
            </div>
            <div id="page-wrapper">
                <div class="container-fluid col-md-7 col-sx-12">
                    <form method="post" enctype="multipart/form-data" name="cater">
                        <div class="form-group"style="margin-left:px">
                            <label for="department"><strong>所在部门：</strong></label>                           
                            <select name="department" value="<?=$tDatas['0']['department']?>" disabled="false">
                                <option value="0"><?=$tDatas['0']['department']?></option>
                                <?foreach($tDIDatas as $tDRow){?>
                                <option value="<?=$tDRow['num']?>"><?=$tDRow['introduce']?></option>
                                <?}?>
                            </select>
                <button type="button" id="save" class="btn btn-blue" style="height:30px;text-align:top;border-radius:10%;margin-left:312px;"><span style="position:relative;bottom:9px;" class="text">修改</span></button>
                        </div>
            
                        <div class="form-group">
                            <span>配餐时间：</span>
                <input type="text" style="" name="startcreated" id="startdatetime" placeholder="开始时间" value="<?=$tDatas['0']['starttime']?>" disabled="true"/>—————<input type="text" name="endcreated" id="enddatetime" placeholder="结束时间" value="<?=$tDatas['0']['endtime']?>" disabled="true"/>            
                <input type="text"  name="cid" id="cid" style="display:none" value="<?=$tDatas['0']['id']?>">              
                        </div>
                        <?foreach($tDatas as $key =>$val){?>

                        <div class="form-group"><input type="text" value="<?=$val[catertime]?>" style="display:none" name="datetime<?=$key?>" /><label for="name"><strong><?=$val['week']?></strong></label><br><span style="margin-left:20px;">早上配餐</span><input class="Create<?=$key?>" type="text" name="breakfast<?=$key?>" style="margin-left:20px;margin-top:20px;" value="<?=$val['breakfast']?>"></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">中午配餐</span><input class="Create<?=$key?>" type="text" name="lunch<?=$key?>" style="margin-left:20px;margin-top:20px;" value="<?=$val['lunch']?>"></br><div style="margin-left:71px;margin-top:20px;align:center"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">晚上配餐</span><input class="Create<?=$key?>" type="text" name="dinner<?=$key?>" style="margin-left:20px;margin-top:20px;" value="<?=$val['dinner']?>"></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">其他</span><input class="Create<?=$key?>" type="text" name="other<?=$key?>" style="margin-left:47px;margin-top:20px;" value="<?=$val['other']?>"></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div>
                        <script>
                        <?if ($val['status']==1) {?>
                            $(".Create<?=$key?>").attr("readonly","readonly")
                        <?}?>
                        </script>
                        <?}?>
                        <div id="cater">
                        </div>
                       <!--  <button class="btn btn-primary demo_2" type="button" id="submit">添加</button> -->
                    </form>   
                </div>
                </div>
                <div class="subviews">
                    <div class="subviews-container"></div>
                </div>
            </div>
            <!-- end: PAGE -->
        </div>
    </div>
</div>
<!-- end: MAIN CONTAINER -->
<script type="text/javascript" src="/plugins/jquery-ui-1.11.4/jquery-ui.min.js"></script>
 <script type="text/javascript" src="/plugins/medialog/mdialog.js"></script><!--medialog -->
 <script type="text/javascript" src="/plugins/medialog/zepto.min.js"></script><!--zepto -->
 <script type="text/javascript" src="/plugins/datepicker/WdatePicker.js" charset="UTF-8"></script>
<script>
var w_id = '';
    //所在部门与姓名绑定显示
    $('select[name="department"]').on('change',function(){
        var department_id = $(this).val();
        $.get('/admin_admin/add',{department_id:department_id},function(obj){
            $('select[name="w_id"]').remove();
            if(obj.status == 1){
                var data = obj.data;
                var html = (
                    '<select name="w_id">'
                );
                $.each(data,function(key,row){
                    html += '<option value="'+row.id+'">'+row.name+'</option>';
                });
                html += '</select>';
                $('.name').after(html);
            }
        });
    });
    $('select[name="role"]').on('change',function(){
        var role = $(this).val();
        w_id = $('select[name="w_id"]').val();
        $.get('/admin_admin/add',{role:role,w_id:w_id},function(obj){
            if(obj.status ==  1){
                var data = obj.data;
                $('input[name="department[]"]').remove();
                $('.introduce').remove();
                for(i in data){
                    $('.department').after('<input type="checkbox" name="department[]" value="'+data[i].num+'" style="margin-left:20px;"/><span class="introduce">'+data[i].introduce+'</span>');
                }
            }
        });
    });
    $('#save').click(function(){
        var data = $('form[name="cater"]').serialize();
        $.post('/admin_cater/detail',data,function(obj){
            cg_alert_edit(obj,'/admin_cater/',"/admin_cater/detail?cid=<?=$tDatas['0']['id']?>");
        });
    });
</script>
<?php include PATH_TPL."/admin/tpl.footer.phtml"?>
